/**
 * 
 */

layui.use('layer', function() {
	var layer = layui.layer;
	/*******************删除单个消息******************************/
	$("[name='delete']").click(function(){
		var messageId = $(this).attr("id");
		$.ajax({
			type:'POST',
			url:'/message/deleteOne.do',
			data:{
				messageId:messageId
			},
			success:function(value){
				if(value=="success"){
					layer.msg("删除成功", {
						icon : 1,
						time : 500
					},function(){
						window.location.href="/user/usermessage.do";
					});
				}else if(value=="false"){
					layer.msg("服务器好像出错了，请稍后重试", {
						icon : 2,
						time : 500
					},function(){
						window.location.href="/user/usermessage.do";
					});
				}
			}
		})
	});
	
	/********************删除所有文章********************/
	$('#B_delallmsg').click(function(){
		$.ajax({
			type:'POST',
			url:'/message/deleteAll.do',
			success:function(value){
				if(value=="unlogin"){
					layer.msg("登录已过期，请重新登录", {
						icon : 1,
						time : 500
					},function(){
						window.location.href="/login.html";
					});
				}else if(value=="success"){
					layer.msg("删除成功", {
						icon : 1,
						time : 500
					},function(){
						window.location.href="/user/usermessage.do";
					});
				}else if(value=="false"){
					layer.msg("服务器好像出错了，请稍后重试", {
						icon : 2,
						time : 500
					},function(){
						window.location.href="/user/usermessage.do";
					});
				}
				
			}
		})
	})
	
});